﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using BLL;
using DAL;
using Models;

using Gift.DAL;
using Gift.Model;

public partial class cn_UserControl_category_brand : System.Web.UI.UserControl
{
    // Fields
    protected BrandManager bm = new BrandManager();
    protected CategoryManager cm = new CategoryManager();
    protected string moduleSetXmlPath = "/cn/xml/module_set.xml";
    readonly DALClass theClass = new DALClass();
    readonly DALPinpai thePinpai = new DALPinpai();
    readonly DALProductclass theProductClass = new DALProductclass();

    // Methods
    protected StringBuilder CategoryBrand()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            builder.AppendLine("<div class=\"pro_nav\">");
            builder.AppendLine("<div class=\"content-box\">");
            builder.AppendLine("<div class=\"content-box-header\">");
            builder.AppendLine("<div class=\"more\"></div>");
            builder.AppendLine("<ul class=\"content-box-tabs\">");
            builder.AppendLine("<li><a href=\"#tab3\" class=\"default-tab\">所有分类</a></li>");
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.moduleSetXmlPath));
            XmlElement element = document.SelectSingleNode("set/brand_category") as XmlElement;
            if (element.GetAttribute("isShow") == "true")
            {
                builder.AppendLine("<li><a href=\"#tab4\">" + element.GetAttribute("title") + "</a></li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"content-box-content\">");
            builder.AppendLine("<div class=\"tab-content default-tab\" id=\"tab3\">");
            DataTable table = theClass.GetMenuList(0);
            //DataTable table = this.cm.GetCategoryByParentIdAndLanguageVersionAndIsShow("00000000-0000-0000-0000-000000000000", "zh-CN", 1);
            foreach (DataRow row in table.Rows)
            {
                builder.AppendLine("<div class=\"pro_class\">");
                builder.AppendLine("<span class=\"one\">" + row["className"] + "</span>");
                builder.AppendLine("<div class=\"class_list\">");
                DataTable table2 = theProductClass.GetHeadMenuLevel2List(int.Parse(row["Classid"].ToString()));
               // DataTable table2 = this.cm.GetCategoryByParentIdAndLanguageVersionAndIsShow(row["id"].ToString(), "zh-CN", 1);
                for (int i = 0; i < table2.Rows.Count; i++)
                {
                    builder.AppendLine(string.Concat(new object[] { "", (i == 0) ? "" : " | ", "<a href=\"/cn/goods_list.html?cid=", table2.Rows[i]["classId"], "\">", table2.Rows[i]["className"], "</a>" }));
                }
                builder.AppendLine("</div>");
                builder.AppendLine("<div class=\"clear\"></div>");
                builder.AppendLine("</div>");
            }
            builder.AppendLine("</div>");
            if (element.GetAttribute("isShow") == "true")
            {
                builder.AppendLine("<div class=\"tab-content\" id=\"tab4\">");
                builder.AppendLine("<ul class=\"brand2\">");
               // DataTable brandByLanguage = this.bm.GetBrandByLanguage("zh-CN");
                DataTable dtBrand = thePinpai.GetList(" languages = 1 ").Tables[0];
                foreach (DataRow row2 in dtBrand.Rows)
                {
                    builder.AppendLine(string.Concat(new object[] { "<li><a href=\"/cn/goods_list.html?bid=", row2["pinpaiid"], "\"><img src=\"", row2["pinpaiLogo"], "\" alt=\"", row2["pinpaiName"], "\" /></a></li>" }));
                }
                builder.AppendLine("</ul>");
                builder.AppendLine("<div class=\"clear\"></div>");
                builder.AppendLine("</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}